#include <iostream>
//#include <windows.h>
#include <time.h>
#include <string>
#include "reflect_json.hpp"


enum  class RequestCmd {
    error   = 0,
    scan_start = 1,
    scan_pause,
    scan_stop,

    scan_set_param,
    scan_get_param,

    scan_get_data,
    scan_get_status,

    mech_get_pos,
    end = 256
};

enum  PieceType {
    piece_1 = 1,
    piece_2,
    piece_3,
    piece_4,
};

enum  RetMsgType {

    success = 1,
    failed,
    timeout,
};





struct RequestMsg {
    int msg_id = 100;
    double msg_double = 20.5;
    RequestCmd req_cmd = RequestCmd::mech_get_pos;
    RetMsgType ret_cmd = RetMsgType::failed;

    std::string extra_msg = "hello world" ; /* reflect_json::serialize(ScanParam()); */
    char padding[100] = "hello world";
    REFLECT(msg_id,msg_double, req_cmd,ret_cmd,extra_msg,padding)
};


int main(int argc, char* argv[]) {
    RequestMsg req_msg;
    req_msg.req_cmd = RequestCmd::scan_set_param;

    auto s = reflect_json::serialize(req_msg);
    std::cout << "serialize object:" << s << std::endl;
    auto p2 = reflect_json::deserialize<RequestMsg>(s);

    std::cout << "Deserialized object:" << std::endl;
    std::cout << "msg_id: " << p2.msg_id << std::endl;
    std::cout << "msg_double: " << p2.msg_double << std::endl;
    std::cout << "req_cmd: " << p2.req_cmd << std::endl;

    std::cout << "ret_cmd: " << p2.ret_cmd << std::endl;
    std::cout << "extra_msg: " << p2.extra_msg << std::endl;
    std::cout << "padding: " << p2.padding << std::endl;

    return 0;
}